package com.welsy.iter.vo
{
	import com.adobe.cairngorm.vo.IValueObject;
	import com.welsy.util.Comparable;
	import com.welsy.iter.business.IterQNames;
	import com.welsy.iter.vo.iter.pattern.IterState;
	import packages.Iter.Iter;
		
	[Bindable]	
	public class IterVO implements IValueObject, Comparable 
	{
		public function get identifier() : String
		{
			return String( id );
		}
	
		public function toString() : String
		{
		    var s : String = "IterVO[id=";
		    s += id;
		    s += ", title=";
		    s += title;
		    s += ", parentId=";
		    s += parentIterId;
		    s += " ]";
		    return s;
		}
			
		public var id : Number;
	
		public var title : String;
		
		public var titleUser : String;
		
		public var state:String = "";
				
		public var description:String = "";
		
		public var notes:String = "";
		
		public var webLink:String = "";
		
		public var authorId:String = "1";
		
		public var credits:String = "";
		
		public var creditsNumber:String = "0";
		
		public var parentIterId:String = "0";
		
		
		public function setProperties(item:XML):void
		{			
			this.id = item.child(IterQNames.qnIterID);
			this.title = item.child(IterQNames.qnTitle).toString ();
			this.titleUser = item.child(IterQNames.qnTitleUser).toString ();			
			this.state = item.child(IterQNames.qnElState).toString ();
            this.description = item.child(IterQNames.qnElDescription).toString ();
            this.authorId = item.child(IterQNames.qnElAuthorID).toString ();
            this.parentIterId = item.child(IterQNames.qnIterParentIterId).toString ();
            this.credits = item.child(IterQNames.qnIterCredits).toString ();
            this.creditsNumber = item.child(IterQNames.qnIterCreditsNumber).toString ();
            this.webLink = item.child(IterQNames.qnIterWebLink).toString ();
            this.notes = item.child(IterQNames.qnIterNote).toString ();     
		}
		
		public function setPropertiesByIter(item:Iter):void
		{			
			this.id = Number(item.iterId)
			this.title = item.title
			this.titleUser = item.titleUser
			this.state = item.state
            this.description = item.description
            this.authorId = item.authorId
            this.parentIterId = item.parentIterId
            this.credits = item.credits
            this.creditsNumber = item.creditsNumber
            this.webLink = item.webLink
            this.notes = item.notes
		}
		
		public function editabled():Boolean
		{
			if (this.state == IterState.publish)
				return false
		    else
		    	return true
		}
		
		public function disableItem():Boolean
		{
			if ((this.state == IterState.publish) || (this.parentIterId != "0"))
				return true
		    else
		    	return false
		}		
	}

}